﻿Imports System.Collections.Generic
Imports System.IO
Imports System.Globalization

Partial Class Public_GetData
    Inherits My.MyPage

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim dat As New clsData
        Dim sql As New MyStringBuilder

        Dim gv As New GridView
        gv.AutoGenerateColumns = False
        gv.AllowPaging = False

        sql.Length = 0

        sql.AppendFormat(" Select vi.TownName+vi.RegionName as TownName,vv.VOrganizationName, ")
        sql.AppendFormat(" v.VolunteerName,v.identificationID,v.Birthday ")
        sql.AppendFormat(" From Volunteer v ")
        sql.AppendFormat(" Left Join Village vi ON v.VillageID = vi.RegionID ")
        sql.AppendFormat(" Left Join VOrganizationMapping vm ON v.VolunteerID = vm.VolunteerID ")
        sql.AppendFormat(" Inner Join VOrganizationView vv ON vm.VOrganizationID = vv.VOrganizationID ")
        sql.AppendFormat(" where (v.Birthday is null Or v.Birthday = '') ")
        sql.AppendFormat(" Order By vi.TownName+vi.RegionName ")




        MyObj.AddBoundField(gv, "TownName", "鄉鎮市村里")
        MyObj.AddBoundField(gv, "VOrganizationName", "志工隊")
        MyObj.AddBoundField(gv, "VolunteerName", "姓名")
        MyObj.AddBoundField(gv, "identificationID", "身分證")
        MyObj.AddBoundField(gv, "Birthday", "生日")

        gv.DataSource = dat.GetData(sql)
        gv.DataBind()

        If gv.Rows.Count <= 0 Then
            MyObj.ShowMessage(Me.GetLocalResourceObject("NoData"))
            Return
        Else
            gv.Page = Me.Page
            MyObj.ExportToExcel(gv, "Volunteer.xls")
        End If

    End Sub

    Public Overrides Sub VerifyRenderingInServerForm(ByVal control As System.Web.UI.Control)

    End Sub
End Class
